/**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

* http://www.apache.org/licenses/LICENSE-2.0

* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.

* File sample_process.h
* Description: handle acl resource
*/
#pragma once
#include "utils.h"
#include "atlas_type.h"
#include "acl/acl.h"
#include "extractor.h"
#include "tracker_manager.h"
#include "nn_matching.h"
#include <memory>
#include <utility>
#include <vector>
#include "deepsort/mot_drawer.h"

using namespace std;

struct TrackData {
    KalmanTracker kalman;
    FeatureBundle feats;
};

/**
* ClassifyProcess
*/
class DeepSort {
public:
    DeepSort(const char* modelPath, 
                 uint32_t modelWidth, uint32_t modelHeight);
    ~DeepSort();
    

    Result Init(int32_t& deviceId, aclrtContext& context, aclrtStream& stream, aclrtRunMode& runMode);
    Result Set(uint32_t width, uint32_t height);
    void DestroyResource();

    Result Process(cv::Mat& ori_img, 
                            std::vector<BBox> &detections, std::vector<BBox>& trackResults);

    void DrawTrajectories(cv::Mat& ori_img, vector<BBox>& trackResults, bool isDrawTrajectory);

private:

    std::vector<TrackData> data;
    std::shared_ptr<Extractor> extractor;
    std::shared_ptr<TrackerManager<TrackData>> manager;
    std::shared_ptr<FeatureMetric<TrackData>> feat_metric;

    std::shared_ptr<MotDrawer> drawer;

    bool isInited_;
};

